<?php
// echo '11111';

// // 远程登录 例子一 ----------------------------------------------------------------------------------------------------------------------

// function f_s_tojs($s){
// 	return preg_replace("#\\\u([0-9a-f]+)#ie", "iconv('UCS-2', 'UTF-8', pack('H4', '\\1'))", $s);
// }

// // 设置cookie
// $cookie_file = tempnam("tmp","cookie");

// // 先获取cookies并保存
// $url = "http://www.4318.com/login/login_ajax?email=f00001@qq.com&password=111111";
// $post_fields = ''; //post参数 如:email=f00001@qq.com&password=111111
// $ch = curl_init($url); //初始化
// curl_setopt($ch, CURLOPT_HEADER, 0); //不返回header部分
// //curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:28.0) Gecko/20120722 Firefox/28.0");
// curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
// curl_setopt($ch, CURLOPT_NOBODY, true);
// curl_setopt($ch, CURLOPT_POST, 1);
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //返回字符串，而非直接输出
// curl_setopt($ch, CURLOPT_COOKIEJAR,  $cookie_file); //存储cookies
// $aa = curl_exec($ch);
// curl_close($ch);

// echo f_s_tojs($aa);

// // 显示cookie
// $file_get_contents = file_get_contents($cookie_file);
// echo str_replace(PHP_EOL, '<BR />', $file_get_contents);


// //使用上面保存的cookies再次访问
// $url = "http://www.4318.com/membercenter/index";
// $ch = curl_init($url);
// curl_setopt($ch, CURLOPT_HEADER, 0);
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); //使用上面获取的cookies
// $response = curl_exec($ch);
// curl_close($ch);
// echo $response;
// //var_dump($response);


// 远程例子2 阿里妈妈


function curl(){
	/*
	$url='https://www.alimama.com/member/minilogin_act.htm';
	$url2='http://www.alimama.com/member/minilogin.htm';
	$data['_tb_token_']=$this->g($url2);
	$data['style']='';
	$data['redirect']='';
	$data['proxy']='http://www.alimama.com/proxy.htm';
	$data['logname']='aaaaaa;
	$data['originalLogpasswd']='bbbbb';
	$data['logpasswd']='567aassssssssssssssssssssssss0f4';
	$fields=array_map('urlencode', $data);
	$cookie_file = "d:\cookie.txt";
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; rv:25.0) Gecko/20100101 Firefox/25.0');
	curl_setopt($ch, CURLOPT_RETURNTRANSFER,0);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
	curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
	curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_exec($ch);
	curl_close($ch);
	*/
} 

